# -*- encoding=utf8 -*-
__author__ = "Bryan.Chen"

from airtest.core.api import *

auto_setup(__file__)

from poco.drivers.std import StdPoco
poco = StdPoco()

using("../FlowTest.air")
import FlowTest

class Club_EnterClub(FlowTest.BaseTestCase):

    def __init__(self):
        print("%s __init__" % (__file__))
    
    def runTest(self, args):

        clubName = "AT_"
        if "clubName" in args:
            clubName = args["clubName"]

        btnClubTab = poco("zixun_button")
        self.clickButton(btnClubTab)
        
        sleep(1.0)
        
        poco("ClubHomePageLayer").wait_for_appearance()

        btnMyJoinNor = poco("my_join_nor")

        if btnMyJoinNor.exists():
            self.clickButton(btnMyJoinNor)
        
        # sleep(1.0)

        myJoinPanel = poco("my_join_panel")
        clubItems = myJoinPanel.offspring("my_join_item")
        isSelect = False
        for item in clubItems:
            txtClubName = item.offspring("club_name")
            if txtClubName.get_text().startswith(clubName):
                self.clickButton(item)
                isSelect = True
                break
        
        if not isSelect: 
            return False
        
        return True

_instance = Club_EnterClub()
runTest = _instance.runTest



